//
//  main.c
//  linear_algebra
//
//  Created by zhangnan on 2025/3/19.
//

#include <stdio.h>
#include "determinant/cal_determinant.h"
#include "maths/fraction.h"
#include "matrix/matrix.h"

int main(int argc, const char * argv[]) {
    // insert code here...
    printf("Hello, World!\n");
    
    // test 按行展开行列式
    /*int arr[9]={1,2,3,4,5,6,7,8,9};
    printf("%d\n",cal_int_determinant_by_row(new_int_determinant(arr, 3)));
    
    double arrd[9]={1.5,-2.3,3.7,4.1,5.9,-6.2,7.8,-8.4,9.5};
    printf("%f\n",cal_double_determinant_by_row(new_double_determinant(arrd,3)));
    printf("---------------------------------------\n");*/
    
    // test 排列组合计算行列式的值
    
    /*int arr[9]={1,2,3,4,5,6,7,8,9};
    printf("%d\n",cal_int_determinant_by_arrange(new_int_determinant(arr, 3)));
    
    double arrd[9]={1.5,-2.3,3.7,
                    4.1,5.9,-6.2,
                    7.8,-8.4,9.5};
    printf("%f\n",cal_double_determinant_by_arrange(new_double_determinant(arrd,3)));
    
    printf("---------------------------------------\n");*/
    
    //测试符号//、、int arr1[9]={1,2,3,1,3,2,2,1,3,2,3,1,3,2,1,3,1,2};
    
    
   // printf("%d\n",cal_cofactor‌‌_symbol(arr1, 3, 1));
    
    double arrd[16]={1,2,3,4,1,4,9,16,1,8,27,64,1,16,81,256};
    //printf("%f\n",cal_double_determinant_by_row(new_double_determinant(arrd,4)));
    //printf("%f\n",cal_double_determinant_by_arrange(new_double_determinant(arrd,4)));
    
    FRACTION_TYPE *a11=new_fraction(1, 2);
    FRACTION_TYPE *a12=new_fraction(2, 3);
    FRACTION_TYPE *a13=new_fraction(3, 4);
    
    FRACTION_TYPE *a21=new_fraction(4, 5);
    FRACTION_TYPE *a22=new_fraction(5, 6);
    FRACTION_TYPE *a23=new_fraction(6, 7);
    
    FRACTION_TYPE *a31=new_fraction(7, 8);
    FRACTION_TYPE *a32=new_fraction(8, 9);
    FRACTION_TYPE *a33=new_fraction(9, 1);
    
    
//    FRACTION_TYPE *a11=new_fraction(1, 1);
//    FRACTION_TYPE *a12=new_fraction(2, 1);
//    FRACTION_TYPE *a13=new_fraction(3, 1);
//    
//    FRACTION_TYPE *a21=new_fraction(4, 1);
//    FRACTION_TYPE *a22=new_fraction(5, 1);
//    FRACTION_TYPE *a23=new_fraction(6, 1);
//    
//    FRACTION_TYPE *a31=new_fraction(7, 1);
//    FRACTION_TYPE *a32=new_fraction(8, 1);
//    FRACTION_TYPE *a33=new_fraction(9, 1);
    
    FRACTION_TYPE* arrf[9]={a11,a12,a13,a21,a22,a23,a31,a32,a33};
    
    MATRIX_FRACTION_TYPE* matrix=create_fraction_matrix(arrf, 3, 3);
    
    print_fraction_matrix(matrix);
    
    trans_to_echelon(matrix);
    
    return 0;
}
